An operator with higher precedence will be performed first. For operators with same precedences, the one appears on the left will be performed first. For examples,
2^3^4 is the same as (2^3)^4. -2^-3^-4 is the same as ((-2)^(-3))^(-4). ⚠️ The precedence table below is different from that in MATLAB's website. For compatibility, parentheses should always be used to explicitly specific the order of operations.
| Precedence | Operator | Symbol |
|---|---|---|
| 1 | Parentheses | () |
| 2 | Transpose | .' |
| 2 | Conjugate Transpose | ' |
| 3 | Unary plus | + |
| 3 | Unary minus | - |
| 4 | Logical NOT | ~ or ! |
| 5 | Power | .^ |
| 5 | Matrix power | ^ |
| 6 | Multiplications | .* or * |
| 6 | Divisions | ./, .\, / or \ |
| 7 | Addition | + |
| 7 | Subtraction | - |
| 8 | Colon | : |
| 9 | Relation operators | <, <=, >, >=, ==, ~= or != |
| 10 | Logical AND | & or && |
| 11 | Logical OR | | or || |